/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vek.Objects;

import vek.XML.parsedObjects.ParsedProduct;

/**
 * Product which the POIs may have. A product is simply a good that the POI sells.
 * It has a name, a type and a price.
 * @author Christian, Michal og Jakob (Hold 1, gruppe 2)
 */
public class Product {
    
    private String nameOfProduct;
    private String typeOfProduct;
    private double priceOfProduct;
    
    /**
     * Creates a Product object and assigns its varaibles using data from the corrosponding ParsedObject.
     * @param pp the ParsedProduct which contains data from the XML files which this product is based on.
     */
    
    public Product(ParsedProduct pp)
    {
        nameOfProduct = pp.nameOfProduct;
        typeOfProduct = pp.typeOfProduct;
        priceOfProduct = pp.priceOfProduct;
    }
    
    /**
     * Checks if to products are equal.
     * To products are equal if the names and types of the to products are the same.
     * 
     * NOTE: price is not checked, thus to products can be considered the same even if their prices are different.
     * 
     * @param o the Product to compare this product to
     * @return true if the names and types are the same.  
     */
    
    public boolean equals(Object o)
    {
        Product p = (Product) o;
        
        if(p.nameOfProduct.equals(this.nameOfProduct) && typeOfProduct.equals(this.typeOfProduct)) // does not check price since price varies from store to store
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    /**
     * Gets the name of this product
     * @return the name of this product
     */
    
    public String getName()
    {
        return nameOfProduct;
    }
    
    /**
     * Gets the type of this product.
     * @return the name of this product.
     */
    
    public String getTypeOfProduct()
    {
        return typeOfProduct;
    }
    
    /**
     * Gets the price of this product as a double
     * @return the price of this product as a double.
     */
    
    public double getPrice()
    {
        return priceOfProduct;
    }
    
    /**
     * Gets the price as a String using the valueOf() method in String
     * @return gets the price as a String 
     */
    
    public String getPriceAsString()
    {
        return String.valueOf(priceOfProduct);
    }
    
    /**
     * Checks if the price of this product is smaller than the price specified
     * @param d the specified price as a double
     * @return true of this product's price is smaller than the specified price.
     */
    
    public boolean priceIsSmallerThan(double d)
    {
        if(priceOfProduct < d)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    /**
     * Checks if the price of this product is larger than the price specified
     * @param d the specified price as a double
     * @return true of this product's price is larger than the specified price.
     */
    
    public boolean priceIsLargerThan(double d)
    {
        if(priceOfProduct > d)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

}
